using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;
 
public partial class JobSeekers_changepassword : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session.Contents["rcuserid"] == null)
        {
            Response.Redirect("login.aspx");
        }
        if (Session["rcactivate"].ToString() == "False")
        {
            btnOK.Enabled = false;
             
            literalError.Text = "<img border=0 src='/icons/warning.gif'>You can not change password, <br>because this account is not approved by management team.";
        }
    }

    protected void btnOK_Click(object sender, EventArgs e)
    {
        try
        {
            MailProvider mailProvider = new MailProvider();
            RecruitVietnam cls = new RecruitVietnam();
            cls.ConnectionString = 
            WebConfigurationManager.ConnectionStrings[
               "RecruitVietnam"].ConnectionString;
            string rcemail = Convert.ToString(Session["rcemail"]);
            if (rcemail == "")
                Response.Redirect("login.aspx");
            if (cls.ChangePassword(rcemail, 
            txtOldPassword.Text, txtPassword.Text, "1"))
            {
                literalError.Text = 
                "You have changed password successful."
                +"<br>It will be effected on next time";

                mailProvider.SendMail(rcemail,
                "Changed Password", "Your password "+
                "have been changed.<br>Thanks you for" +
                " using RecruitVietnam.com service.");                 
                btnOK.PostBackUrl = "myaccount.aspx"; 
            }
            else
            {
                literalError.Text = 
                "Sorry, your password is not correct."
                + cls.ErrorMessage;
                 
            }
        }
        catch(Exception ex)
        {
            literalError.Text = ex.Message;
        }
    }
}
